// Fill out your copyright notice in the Description page of Project Settings.

#include "MultiThread.h"
#include "MultiThreadGameInstance.h"
#include "CSingleton.h"
#include "ThreadManager.h"
#include "TestTask.h"



UMultiThreadGameInstance::UMultiThreadGameInstance()
{

}

void UMultiThreadGameInstance::Init()
{
	Super::Init();
	CSingleton<CThreadManager>::CreateInstance(10);
	CThreadManager *pThreadManager = CSingleton<CThreadManager>::GetInstance();
	int32 num = pThreadManager->AllThreadNum();
	UE_LOG(LogClass, Log, TEXT("ALL THREAD NUM:%d"), num);
	CTestTask *task = new CTestTask();
	pThreadManager->RunBackground(std::bind(&CTestTask::test, task));

}

void UMultiThreadGameInstance::Shutdown()
{
	CThreadManager *pThreadManager = CSingleton<CThreadManager>::GetInstance();
	CSingleton<CThreadManager>::DestroyInstance();
	Super::Shutdown();
}
